import tkinter as tk
from tkinter import messagebox
from db import db
from AdminViews import SelectFrame
from StaffViews import UpworkFrame, LeaveFrame, LeaveFrame, LeaveSelectFrame

class StaffPage:
    def __init__(self, root):
        self.root = root
        self.root.title('员工管理系统')
        self.root.geometry('600x400')
        # 创建菜单栏
        self.create_page()
        # 初始化菜单按钮数据
        self.init_show()

    def create_page(self):
        menubar = tk.Menu(self.root)
        menubar.add_command(label='查询员工信息', command=self.show_select)
        menubar.add_command(label='员工请假申请', command=self.show_leave)
        menubar.add_command(label='员工请假进度查看', command=self.show_leave_select)
        menubar.add_command(label='员工上班打卡', command=self.show_upwork)
        menubar.add_command(label='员工下班打卡', command=self.show_downwork)
        self.root['menu'] = menubar


    #初始化菜单类
    def init_show(self):
        self.select_frame = SelectFrame(self.root)
        self.upwork_frame = UpworkFrame(self.root, '上班', 'upwork')
        self.downwork_frame = UpworkFrame(self.root, '下班', 'downwork')
        self.leave_frame = LeaveFrame(self.root)
        self.leave_select_frame = LeaveSelectFrame(self.root)

    #显示查询功能
    def show_select(self):
        self.select_frame.show_clear()
        self.select_frame.pack()
        # 隐藏无关界面
        self.upwork_frame.pack_forget()
        self.downwork_frame.pack_forget()
        self.leave_frame.pack_forget()
        self.leave_select_frame.pack_forget()

    #显示上班打卡功能
    def show_upwork(self):
        self.upwork_frame.entry_clear()
        self.upwork_frame.pack()
        self.downwork_frame.pack_forget()
        # 隐藏无关界面
        self.select_frame.pack_forget()
        self.downwork_frame.pack_forget()
        self.leave_frame.pack_forget()
        self.leave_select_frame.pack_forget()

        # 显示下班打卡功能
    def show_downwork(self):
        self.downwork_frame.entry_clear()
        self.downwork_frame.pack()
        # 隐藏无关界面
        self.select_frame.pack_forget()
        self.upwork_frame.pack_forget()
        self.leave_frame.pack_forget()
        self.leave_select_frame.pack_forget()

    # 显示提交请假界面
    def show_leave(self):
        self.leave_frame.entry_clear()
        self.leave_frame.pack()
        #隐藏无关节面
        self.upwork_frame.pack_forget()
        self.downwork_frame.pack_forget()
        self.select_frame.pack_forget()
        self.leave_select_frame.pack_forget()

    def show_leave_select(self):
        self.leave_select_frame.show_clear()
        self.leave_select_frame.pack()
        #隐藏无关节面
        self.upwork_frame.pack_forget()
        self.downwork_frame.pack_forget()
        self.select_frame.pack_forget()
        self.leave_frame.pack_forget()



if __name__ == '__main__':
    root = tk.Tk()
    app = StaffPage(root)
    root.mainloop()